package com.ruipengkj.component;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;

import com.ruipengkj.factory.ImageFactory;

public class RPJButtonCooking extends JToggleButton {

	private static final long serialVersionUID = 1L;
	
	ImageIcon icon1 = ImageFactory.loadImage(ImageFactory.BTN_COOKING);
	ImageIcon icon2 = ImageFactory.loadImage(ImageFactory.BTN_COOKING_CLICK);
	
	private String parentName = "";
	private String Name = "";
	
	public RPJButtonCooking(String text){
		super(text);
		setContentAreaFilled(false); // 这一句非常重要, 否则父类还会绘制按钮的区域.
		setFocusPainted(false);
		setBorderPainted(false);
		setSize(117, 57);
		setCursor(new Cursor(Cursor.HAND_CURSOR));
		setHorizontalTextPosition(SwingConstants.CENTER);//水平对齐方式
		setIcon(icon1);
		this.setBackground(Color.black);
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		if (getModel().isSelected()) {
			setIcon(icon2);
			setForeground(new Color(253, 107, 0));
		} else {
			setIcon(icon1);
			setForeground(Color.black);
		}
		super.paintComponent(g);
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}

	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}
}
